//
//  B_SearchActivityVC.m
//  DreamOf
//
//  Created by 薛小刚 on 2018/8/27.
//  Copyright © 2018年 薛小刚. All rights reserved.
//

#import "B_SearchActivityVC.h"
#import "B_SearchTopicTVC.h"
#import "B_SearchTopicModel.h"
#import "B_ActivityDetailVC.h"

@interface B_SearchActivityVC ()

@end

@implementation B_SearchActivityVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view = self.mainView;
}


- (BaseTableView *)mainView {
    if (!_mainView) {
        WeakSelf(weSelf, self);
        _mainView = [[BaseTableView alloc] init];
        [_mainView setTableViewFrameWithTop:5 left:0 right:0 bottom:0];
        
        [_mainView.tableView registerNib:[UINib nibWithNibName:@"B_SearchTopicTVC" bundle:nil] forCellReuseIdentifier:@"B_SearchTopicTVC"];
        _mainView.numberOfSectionsBlock = ^NSInteger(UITableView *tableView) {
            return 1;
        };
        _mainView.numberOfRowsBlock = ^NSInteger(UITableView *tableView, NSInteger section) {
            return weSelf.dataArray.count;
        };
        
        _mainView.cellForRowBlock = ^UITableViewCell *(UITableView *tableView, NSIndexPath *indexPath) {
            B_SearchTopicTVC * cell = [tableView dequeueReusableCellWithIdentifier:@"B_SearchTopicTVC" forIndexPath:indexPath];
            B_SearchTopicModel * model = weSelf.dataArray[indexPath.row];
            cell.B_titleLabel.text = model.title;
            return cell;
        };
        _mainView.heightForRowBlock = ^CGFloat(UITableView *tableView, NSIndexPath *indexPath) {
            return 44;
        };
        _mainView.didSelectRow = ^(UITableView *tableView, NSIndexPath *indexPath) {
            B_SearchTopicModel * model = weSelf.dataArray[indexPath.row];
            B_ActivityDetailVC * vc = [[B_ActivityDetailVC alloc] init];
            vc.activityId = model.id;
            [weSelf pushNextViewController:vc];
        };
        
    }
    return _mainView;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
